package com.wigem.approve.controller;

import com.wigem.approve.entity.DaqPolicyEntity;
import com.wigem.approve.entity.ElementPlusTableModel;
import com.wigem.approve.service.ExportService;
import com.wigem.approve.vo.DaqEstateVo;
import com.wigem.approve.vo.DaqPolicyVo;
import com.wigem.framework.operate.log.core.annotations.OperateLog;
import com.wigem.framework.operate.log.core.enums.OperateTypeEnum;
import com.wigem.framework.sa.token.core.annotation.IgnoreAuth;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/approve/export")
public class ExportController {
    @Resource
    private ExportService exportService;


    @IgnoreAuth
    @ResponseBody
    @GetMapping("/word/estate")
    @ApiOperation("商务楼宇信息登记表")
    @OperateLog(name = "商务楼宇信息登记表", type = OperateTypeEnum.GET, module = "商务楼宇信息登记表")
    public void exportEstate(HttpServletResponse httpServletResponse, DaqPolicyVo daqPolicyVo) throws Exception {
        exportService.exportEstate(httpServletResponse,daqPolicyVo);
    }

    @IgnoreAuth
    @ResponseBody
    @GetMapping("/zip/policy")
    @ApiOperation("商务楼宇信息登记表")
    @OperateLog(name = "商务楼宇信息登记表", type = OperateTypeEnum.GET, module = "商务楼宇信息登记表")
    public void exportPolicy(HttpServletResponse httpServletResponse, DaqPolicyVo daqPolicyVo) throws Exception {
        exportService.exportPolicy(httpServletResponse,daqPolicyVo);
    }

    @IgnoreAuth
    @ResponseBody
    @GetMapping("/zip/all")
    @ApiOperation("政策申报文件")
    @OperateLog(name = "政策申报文件", type = OperateTypeEnum.GET, module = "政策申报文件")
    public void exportAll(HttpServletResponse httpServletResponse, DaqPolicyVo daqPolicyVo) throws Exception {
        exportService.exportAll(httpServletResponse,daqPolicyVo);
    }

    @ResponseBody
    @PostMapping("/excel/table")
    public void excelTable(HttpServletResponse response, @RequestBody ElementPlusTableModel elementPlusTable) {
        try {
            exportService.exportExcel(response, elementPlusTable);
        } catch (Exception ex) {
            System.out.print(ex);
        }
    }
}
